<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="content.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
	<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb">您现在的位置:<a href="${ctx}/main.action">首页</a><span>></span>站内内容导出</div>
	<div class="listtit" id="listtit"><p><span><strong>内容导出><s:property value="content.category.catName"/></strong></span></p></div>
	 
	<div class="listbox" id="listbox">
		<table class="listgrid" id="listtable">
			<tbody>
				<tr>
					<th>栏目选择</th>
					<th style="width: 80%;height: 100%">操作</th>
					 
				</tr>
				<tr>
					<td style="height: 100%;text-align: left;">
				 		<div id="ztree_content" class="ztree" style="overflow-y:auto;overflow-x:auto;height:300px;width:200px"></div>
					</td>
					<td style="height: 100%" id="before">
						 <table class="listgrid" >
						 	<s:form method="POST" name="thisForm" id="thisForm" target="uploadIframe">
						 	<tr>
						 		<th>条件</th>
						 		<td colspan="3">
									<label for="search" class="labelKeywords">文章类型:</label>
									<s:select list="contentTypes" name="content.docType" cssClass="selectClass"  listKey="key" listValue="value"  headerKey="" headerValue="---请选择---"/>
						 			<label for="qry_contentStatus">文章状态: </label>
						 			<s:select list="dicContentType" name="content.contentStatus" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue" headerKey="" headerValue="---请选择---"/>
						 			<label for="search" class="labelKeywords">起始时间:</label>
						 			<input name="content.startTime"  class="Wdate" id="qry_startTime" readonly="true"  value="<s:property value="%{formatDate(content.startTime)}"/>"
										onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'qry_endTime\')||\'2030-10-01\'}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/>
						 			<label for="search" class="labelKeywords">终止时间:</label>
						 			<input name="content.endTime"  class="Wdate" id="qry_endTime" readonly="true"  value="<s:property value="%{formatDate(content.endTime)}"/>"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'qry_startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/>
						 		</td>
						 	</tr>
						 	<tr>
						 		<th>导入</th>
						 		<td>
									<%-- <s:form enctype="multipart/form-data" action="content-file-import" 
												id="uploadForm" method="POST" name="uploadForm" target="uploadIframe">
									</s:form> --%>
						 				<s:hidden id="targetCategoryId" name="categoryId"/> 
							 			<s:file id="file_path_file" name="upload" cssClass="normal w350" cssStyle="hight:200px;"/>
								</td>
						 		<td><input type="button" value="导入" class="btnlist2" id="top_anti_btn"/></td>
						 		<td>上传类型：xml、zip（xml文件的zip包）</td>
						 	</tr> 
						 	<tr></tr>
						 	<tr>
						 		<th>导出</th>
						 		<td>
								<%-- 	<s:form  action="content-file-export" 
												id="exportForm" method="POST" name="exportForm" target="uploadIframe">
							 			<s:hidden id="targetCategoryId2" name="categoryId"/>
						 			</s:form> --%>
							 			<input type="radio" id="file_xml" name="fileType" value="xml" checked="checked"/>
							 			<label for="file_xml" class="labelKeywords">XML</label>
							 			<input type="radio" id="file_doc"name="fileType" value="doc">
							 			<label for="file_doc" class="labelKeywords">DOC</label> 
						 		</td>
						 		<td><input type="button" value="导出" class="btnlist2" id="exp_anti_btn"/></td>
						 		<td> </td> 
						 	</tr>
						 	</s:form>
						 	<tr>
								<td></td><td></td><td> </td><td> </td>
							</tr>
							<tr> 
								<td colspan="4">
									<iframe name="uploadIframe" id="uploadIframe" frameborder="0" class="listgrid">
										 
									</iframe>	
								</td>
							</tr>
						 </table>
					</td> 
				</tr>
				
			</tbody>
		</table> 
	</div>
 
</div>

</div>
 
<div id='error' style="display: none"><s:actionmessage /></div>
</div> 
 
<div id="lightbox_p" class="lightbox" >
	<div class="lighttit"><p><span><strong>发布文章</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit"><label id="returnInfo">正在发布文章....</label>
		</div>
		<div class="lightbtnbox">请稍等.....</div>
	</div>
</div>
</body>
</html>
<link href="${ctx}/css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${ctx}/js/jquery.ztree.core-3.0.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.ztree.excheck-3.0.js"></script>
<script type="text/javascript">
$(function(){
	loadCatetree(false,false,'ztree_content');	 
	$("#top_anti_btn").click(function(){		
		if(!$("#file_path_file").val()){
			alert("请先选择要导入的文件");
			return;
		}
		if(!$("#targetCategoryId").val()){
			alert("请先选择要导出的对象栏目");
			return;
		}
		
		$("#thisForm").attr("enctype","multipart/form-data");
		$("#thisForm").attr("action","${ctx}/content/content-file-import.action");
		$("#thisForm").submit();
		$("#file_path_file").val(''); 
	});
	
	$("#exp_anti_btn").click(function(){
		if(!$("#targetCategoryId").val()){
			alert("请先选择要导出的对象栏目");
			return;
		}
		if($("#file_doc").attr("checked")){
			alert("暂不支持doc格式的导出");
			return; 
		}
		$("#thisForm").attr("action","${ctx}/content/content-file-export.action");
		if($("#thisForm").attr("enctype")){			
			$("#thisForm").removeAttr();
		}
		$("#thisForm").submit();
	});
});
var setting = {
		check: {
			enable: true,
			chkStyle: "radio",
			radioType: "all"
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onCheck: zTreeOnCheck
		}
		
	}; 
function loadCatetree (type,needUrl,id){	
	$.ajax({
		async:false, 
		url:"${ctx}/site/sitetree.action?t="+new Date().getTime(),
		data:{"type":type,"needurl":needUrl},
		type:"post",
		dataType:"text",
		success:function(ss){
			var zNodes = eval('('+ss+')');
			$.fn.zTree.init($("#"+id), setting, zNodes);			 
		}
	});
} 
function zTreeOnCheck(){  
	var treeObj = $.fn.zTree.getZTreeObj("ztree_content");
	var nodes = treeObj.getCheckedNodes(true)
	for(var i=0;i<nodes.length;i++){
		if(nodes[i].isParent){
			alert('请选择叶子节点');
			nodes[i].nocheck = true;
			treeObj.updateNode(nodes[i]);
		}else{
			$("#targetCategoryId").val(nodes[i].id);
		} 
	} 
} 
</script>
 